﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;

namespace WcfDataService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the interface name "IEmployeeService" in both code and config file together.
    /*
    The ServiceContract attribute class is used to indicate that an interface
    (or class) is a WCF service. The ServiceContract attribute class has parameters
    for setting things such as whether the service requires a session (SessionMode), the
    namespace, the name of the contract, the return contract on a two-way contract
    (CallbackContract), and more.     
     * 
     * (Kapitel 10 - side 597)
     */
    [ServiceContract]
    public interface IEmployeeService
    {
        /*
         The OperationContract attribute class is used to mark methods
        inside an interface (or class) as service operations. Methods marked with OperationContract
        represent those exposed by the service to clients. You can use the parameters of the
        OperationContract attribute class to define settings such as whether the contract does
        not return a reply (IsOneWay), the message-level security (ProtectionLevel), or whether
        the method supports asynchronous calls (AsyncPattern).
         * 
         * (Kapitel 10 - side 597)
         */
        [OperationContract]
        EmployeeDetails GetEmployeeDetails(int empId);

        [OperationContract]
        List<string> GetEmployeeNames();
    }
    /*
     * The DataContract attribute class is used to mark types (classes,
     * enumerations, or structures) that you write as participating in WCF serialization via
     * the DataContractSerializer. Marking your classes with this attribute ensures that they
     * can be sent efficiently to and from disparate clients.
     */
    [DataContract]
    public class EmployeeDetails
    {
        private string _Name;
        private string _LastName;
        private byte[] _Photo;
        private string _PhotoUrl;

        [DataMember]
        public string Name
        {
            get { return _Name; }
            set { _Name = value; }
        }
        [DataMember]
        public string LastName
        {
            get { return _LastName; }
            set { _LastName = value; }
        }
        
        [DataMember]
        public byte[] Photo
        {
            get { return _Photo; }
            set { _Photo = value; }
        }
        [DataMember]
        public string PhotoUrl
        {
            get { return _PhotoUrl; }
            set { _PhotoUrl = value; }
        }
    }
}
